using Autofac;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using VIP.Application.Controllers;
using VIP.Domain.BusServices;
using VIP.Domain.DTO;

namespace VIP.Tester
{
    public class Tests
    {
        public IContainer container;
        [SetUp]
        public void Setup()
        {
            container = ContainerHelper.Builder();
        }

        [Test]
        public void Test1()
        {
            var orderC = new OrderController(container.Resolve<IOrderService>());
            var orderCode = Guid.NewGuid().ToString();
            var customerName = "Сǿ";

            var orderVO = orderC.Create(new Domain.DTO.CreateOrderDTO()
            {
                code = orderCode,
                customerName = customerName,
                Items = new List<OrderItemDTO>() {
                       new OrderItemDTO(){
                          count=10,
                           orderIndex=1,
                            price=66,
                             productCode="P01"
                       },new OrderItemDTO(){
                          count=100,
                           orderIndex=2,
                            price=88,
                             productCode="P02"
                       }
                   }
            }); ;

            var orderVo = orderC.Query(orderCode).Result;
            Assert.AreEqual(customerName, orderVo.Data.CustomerName);

        }
    }
}